
const connection=require("../app/databases")
 
class  AuthService{
     //把表名单独写出来
     async compareMoment(tableName,id,user_id){
          try {
          //判断符合条件
            const statement=`select * from ${tableName} where id=? and user_id=?;`
             console.log(tableName)
            const result=await connection.execute(statement,[id,user_id])
            
            return result[0].length===0?false:true;
          } catch (error) {
               console.log(error)   
         }
     }
     async updateContent(content,momentid){
             try {
               const statement=`update moment set content=? where id=?;`
               const result=await connection.execute(statement,[content,momentid])
               return result;   
             } catch (error) {
                  console.log(error)
             }
            
     }
         //删除动态
     async removeContent(momentid){
          try {
               const statement=`delete from moment where id=?`
               const result=connection.execute(statement,[momentid])
               return result;
          } catch (error) {
              console.log(error)
          }
   }
 
   
}
module.exports=new AuthService()